#include "numericUnaryOperation.h"

NumericUnaryOperation::NumericUnaryOperation(Expression * expression, std::string operatorRep)
{
	if(expression != NULL) Operand = expression->clone();
	else Operand = NULL;
	operatorRepresentation = operatorRep;
}

NumericUnaryOperation::NumericUnaryOperation(const NumericUnaryOperation & other)
{
    if(other.Operand != NULL) Operand = other.Operand->clone();
    else Operand = NULL;
    operatorRepresentation = other.operatorRepresentation;
}

NumericUnaryOperation::~NumericUnaryOperation()
{
    delete Operand; Operand = NULL;
    operatorRepresentation = "";
}

Expression * NumericUnaryOperation::clone()
{
    return new NumericUnaryOperation(*this);
}

std::string NumericUnaryOperation::toString()
{
    std::string str ="("+operatorRepresentation+" ";
    if(Operand != NULL) str = str + Operand->toString();
    return str + ")";
}

Expression * NumericUnaryOperation::getExpression()
{
    return Operand;
}

void NumericUnaryOperation::setExpression(Expression * expression)
{
    delete Operand; Operand = NULL;
    if(expression != NULL) Operand = expression->clone();
}

void NumericUnaryOperation::setOperator(const std::string & opRep)
{
    operatorRepresentation = opRep;
}

std::string NumericUnaryOperation::getOperator()
{
    return operatorRepresentation;
}

